From: Matthieu Gallien Date: Thu, 24 Apr 2025 10:09:48 +0000 (+0200) Subject: fix(assert): remove runtime assert that could crash production builds X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~3^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=72bc312bcaac79547e7c884dbe86bd4da71de4ab;p=nextcloud-desktop.git fix(assert): remove runtime assert that could crash production builds use debug only assert to remove the possibility that we self inflict crashes on users Signed-off-by: Matthieu Gallien --- diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index f0454c97f..26df7db12 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -142,7 +142,7 @@ Folder::Folder(const FolderDefinition &definition, }); // Potentially upgrade suffix vfs to windows vfs - ENFORCE(_vfs); + Q_ASSERT(_vfs); if (_definition.virtualFilesMode == Vfs::WithSuffix && _definition.upgradeVfsMode) { if (isVfsPluginAvailable(Vfs::WindowsCfApi)) { @@ -513,8 +513,8 @@ void Folder::createGuiLog(const QString &filename, LogStatus status, int count, void Folder::startVfs() { - ENFORCE(_vfs); - ENFORCE(_vfs->mode() == _definition.virtualFilesMode); + Q_ASSERT(_vfs); + Q_ASSERT(_vfs->mode() == _definition.virtualFilesMode); const auto result = Vfs::checkAvailability(path(), _vfs->mode()); if (!result) { diff --git a/src/libsync/abstractnetworkjob.cpp b/src/libsync/abstractnetworkjob.cpp index 9b5590fd2..86c9e57b5 100644 --- a/src/libsync/abstractnetworkjob.cpp +++ b/src/libsync/abstractnetworkjob.cpp @@ -483,7 +483,7 @@ QString networkReplyErrorString(const QNetworkReply &reply) void AbstractNetworkJob::retry() { - ENFORCE(_reply); + Q_ASSERT(_reply); auto req = _reply->request(); QUrl requestedUrl = req.url(); QByteArray verb = HttpLogger::requestVerb(*_reply); diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index ec86e7f4e..a97585a18 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -839,7 +839,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(const SyncFileItemPtr &it item->_size = sizeOnServer; if (serverEntry.isDirectory) { - ENFORCE(dbEntry.isDirectory()); + Q_ASSERT(dbEntry.isDirectory()); item->_instruction = CSYNC_INSTRUCTION_UPDATE_METADATA; } else if (!localEntry.isValid() && _queryLocal != ParentNotChanged) { // Deleted locally, changed on server diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 469dec380..9b72732c4 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -249,10 +249,10 @@ void DiscoveryPhase::markPermanentDeletionRequests() void DiscoveryPhase::startJob(ProcessDirectoryJob *job) { - ENFORCE(!_currentRootJob); + Q_ASSERT(!_currentRootJob); connect(this, &DiscoveryPhase::itemDiscovered, this, &DiscoveryPhase::slotItemDiscovered, Qt::UniqueConnection); connect(job, &ProcessDirectoryJob::finished, this, [this, job] { - ENFORCE(_currentRootJob == sender()); + Q_ASSERT(_currentRootJob == sender()); _currentRootJob = nullptr; if (job->_dirItem) emit itemDiscovered(job->_dirItem); diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 30b48ef87..b89e203fc 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -226,7 +226,7 @@ void blacklistUpdate(SyncJournalDb *journal, SyncFileItem &item) void PropagateItemJob::done(const SyncFileItem::Status statusArg, const QString &errorString, const ErrorCategory category) { // Duplicate calls to done() are a logic error - ENFORCE(_state != Finished); + Q_ASSERT(_state != Finished); _state = Finished; _item->_status = statusArg; @@ -1294,7 +1294,7 @@ void PropagatorCompositeJob::slotSubJobFinished(SyncFileItem::Status status) // Delete the job and remove it from our list of jobs. subJob->deleteLater(); int i = _runningJobs.indexOf(subJob); - ENFORCE(i >= 0); // should only happen if this function is called more than once + Q_ASSERT(i >= 0); // should only happen if this function is called more than once _runningJobs.remove(i); // Any sub job error will cause the whole composite to fail. This is important